package com.systemdevelopment.mainproject.View.Visitor;

import com.jfoenix.controls.JFXButton;
import com.jfoenix.controls.JFXPasswordField;
import com.jfoenix.controls.JFXTextField;
import com.systemdevelopment.mainproject.Controller.UserController;
import com.systemdevelopment.mainproject.View.mainUI;
import javafx.event.ActionEvent;
import javafx.fxml.FXML;
import javafx.scene.control.Alert;
import javafx.scene.control.Label;

public class loginPaneController {

    @FXML
    private JFXTextField userNameField;

    @FXML
    private JFXPasswordField PassField;

    @FXML
    private JFXButton gotoRegisterButton;

    @FXML
    private JFXButton loginButton;

    @FXML
    private Label loginTitle;


    @FXML
    void login(ActionEvent event) {
            UserController c =mainUI.getVisitorController().login(userNameField.getText(),PassField.getText());
            if(c!=null)
            {
                mainUI.setUserController(c);
            }
            else
            {
                Alert alert = new Alert(Alert.AlertType.INFORMATION);
                alert.setTitle("登陆失败");
                alert.setHeaderText("登陆失败，请检查账号密码是否有误");
                alert.showAndWait();
            }

    }

    @FXML
    void gotoRegisterPane(ActionEvent event) {
        mainUI.loadRegisterPane();
    }

}
